﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SVM;

namespace ModelPredictPro.Predict.SVM {
    public class SVMFactory : ISVMSetting {
        public SVMFactory() {
            CacheMemorySize = 100;
            KernelType = KernelType.RBF;
        }
        public SVMFactory(double cacheMemorySize, KernelType kernelType, ParameterSelection.ParallelMode parallelModelSetting, bool useProbability, Dictionary<int,double>weights) {
            CacheMemorySize = cacheMemorySize;
            KernelType = kernelType;
            //UseMPI = useParallel;
            ParallelModeSetting = parallelModelSetting;
            UseProbability = useProbability;
            Weights = weights;
        }
        public SVMFactory(ISVMSetting settings) : 
        this( settings.CacheMemorySize, settings.KernelType, settings.ParallelModeSetting, settings.UseProbability, settings.Weights)
        {
        }
        ///<summary>创建一个新的SVMPredict参数（C & Gamma 未赋值）</summary>
        public ISVMPredictParam CreatePredictParam() {
            ISVMPredictParam rst = new SVMPredictParam();
            rst.KernelType = this.KernelType;
            rst.CacheMemorySize = this.CacheMemorySize;
            rst.ParallelModeSetting = this.ParallelModeSetting;
            rst.UseProbability = this.UseProbability;
            rst.Weights = this.Weights;
            return rst;
        }

        //public static double GetSystemMeorySize() {
        //    System.Management.Instrumentation.
        //}

        #region ISVMSetting 成员

        public bool UseProbability { get; set; }

        public ParameterSelection.ParallelMode ParallelModeSetting { get; set; }

        public double CacheMemorySize { get; set; }

        public KernelType KernelType { get; set; }

        public Dictionary<int, double> Weights { get; set; }

        #endregion
    }
}
